From d84f5f3838bda9faa0b7b6f26da4d474ff06e768 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Tue, 31 Jul 2018 00:18:11 -0500 Subject: [PATCH] Rewrite xcsv_parse_style_buff() in a readable way MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …might be more clever with a QStringRef, but this is hardly a performance path. --- xcsv.cc | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/xcsv.cc b/xcsv.cc index a8905a9fe..f617d72e1 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -419,22 +419,9 @@ xcsv_parse_style_line(QString line) static void xcsv_parse_style_buff(const char* sbuff) { - // FIXME: should not be a static buf. Should not be a raw character - // buffer at all! - char ibuf[4096]; - - while (*sbuff) { - ibuf[0] = 0; - size_t i = 0; - char* ibufp; - for (ibufp = ibuf; *sbuff != '\n' && i++ < sizeof(ibuf);) { - *ibufp++ = *sbuff++; - } - while (*sbuff == '\n' || *sbuff == '\r') { - sbuff++; - } - *ibufp = 0; - xcsv_parse_style_line(ibuf); + QStringList lines = QString(sbuff).split('\n'); + for (const auto& line : lines) { + xcsv_parse_style_line(line); } } -- 2.30.2